package cn.j0n4than.api.controller.api.admin;

import cn.j0n4than.api.config.ResponseConfig;
import cn.j0n4than.api.entity.Admin;
import cn.j0n4than.api.entity.Auth;
import cn.j0n4than.api.utils.Response;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;

/**
 * @author jonathan
 */
@RestController
@RequestMapping("/api/admin")
public class AdminHomeController extends AdminBaseController {

    @GetMapping("/getCurrentUserInfo")
    public Response getCurrentUserInfo(HttpServletRequest request) {
        Response response = Response.response();

        Admin currentUser = this.getCurrentUser((Auth) request.getAttribute("auth"));
        currentUser.password = null;

        response.setStatus(ResponseConfig.SUCCESS);
        response.setMessage("success");
        response.setResult("user", currentUser);
        return response;
    }
}
